//
//  MDIVisitorTableVC.swift
//  MDIWeibo
//
//  Created by 迁徙鸟 on 16/4/17.
//  Copyright © 2016年 qianxiniao. All rights reserved.
//

import UIKit

class MDIVisitorTableVC: UITableViewController {

    var isLogin = false
    
//    访客视图
    var visitorView : MDIVisitorView?
    
//   判断是否登录，创建View
    override func loadView() {
        
        if isLogin {
        
        super.loadView()
            
        }else {
        
        setVisitorView()
            setUpNav()
        }
    }
    
//    MARK - 设置导航栏
    private func setUpNav(){
    
    navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "login")
    navigationItem.rightBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "login")
        
    }
    
//    MARK - 实现点击方法
    @objc private func login(){
    
let oauthVc = MDIOAutoVC()
        
        presentViewController(UINavigationController(rootViewController: oauthVc), animated: true, completion: nil)
    
    }
    
//    MARK - 没有登录的时候，创建新的View
    private func setVisitorView(){
    
        visitorView = MDIVisitorView()
        
        visitorView?.visitorClosure = {
        
        self.login()
        }
        
     view = visitorView
    
    }
}
